package com.tanhua.mysqldb.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.api.service.BlackListApi;
import com.tanhua.model.pojo.BlackList;
import com.tanhua.model.pojo.UserInfo;
import com.tanhua.mysqldb.mapper.BlackListMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;

    @Override
    public Page<UserInfo> findBlackPage(Page<UserInfo> pageInfo, Long userId) {
        return blackListMapper.selectPageByUserId(pageInfo, userId);
    }


    @Override
    public void update(Long uid, Long userId) {
        blackListMapper.delete(
                Wrappers.lambdaQuery(BlackList.class)
                        .eq(BlackList::getUserId, userId)
                        .eq(BlackList::getBlackUserId, uid)
        );
    }
}
